$(function() {
	$("#jvForm").validate({
		errorElement: "label",
		errorPlacement: function(error, element) {
			error.appendTo( element.parent("td") );
		},
		rules:{
			username:{
				required:true,
				rangelength: [6,20],
				remote:"username_unique.jspx"
			},
			email:{
				required:true,
				email:true,
				maxlength:30,
				remote:"email_unique.jspx"
			},
			password:{
				required:true
			},
			moble:{
				maxlength:30
			},
			captcha:{
				required:true,
				maxlength:20
			}
		},
		messages:{
			username:{
				required:"请输入用户名",
				rangelength:$.validator.format("用户名长度须在{0}到{1}之间"),
				remote:"用户名已被注册"
			},
			email:{
				required:"请输入邮箱地址",
				email:"邮箱格式有误",
				maxlength:$.validator.format("请不要超过{0}个字符"),
				remote:"邮箱已被注册"
			},
			password:{
				required:"请输入密码"
			},
			confirm:{
				equalTo:"两次输入密码不一致"
			},
			moble:{
				maxlength:$.validator.format("请不要超过{0}个字符")
			},
			captcha:{
				required:"请输入验证码",
				maxlength:$.validator.format("请不要超过{0}个字符")
			}
		},
		submitHandler: function(form) {
			if($("#agreement")[0].checked == false) {
				alert("对不起，您不能注册，请选择\"服务条款\"及\"隐私权保护和个人信息利用政策\"");
				return false;
			} else {
				form.submit();
			}
		}
	});
});